package com.itheima.demogame;


import lombok.*;

import java.util.HashMap;
import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Pocker implements Comparable<Pocker>{
    private String size;
    private String color;
    private static Map<String,Integer> compareSize;
    private static Map<String,Integer> compareColor;
    static {
        compareSize = new HashMap<>();
        compareSize.put("大王",1);
        compareSize.put("小王",2);
        compareSize.put("2",3);
        compareSize.put("A",4);
        compareSize.put("K",5);
        compareSize.put("Q",6);
        compareSize.put("J",7);
        compareSize.put("10",8);
        compareSize.put("9",9);
        compareSize.put("8",10);
        compareSize.put("7",11);
        compareSize.put("6",12);
        compareSize.put("5",13);
        compareSize.put("4",14);
        compareSize.put("3",15);

        compareColor = new HashMap<>();
        compareColor.put("🃏",1);
        compareColor.put("♥",1);
        compareColor.put("♦",2);
        compareColor.put("♣",3);
        compareColor.put("♠",4);
    }

    @Override
    public String toString() {
        return size + color;
    }

    @Override
    public int compareTo(Pocker o) {
        // 从大到小排序
        if (compareSize.get(o.size) == compareSize.get(this.size)) {
            return compareColor.get(o.color) - compareColor.get(this.color);
        }
        return compareSize.get(o.size) - compareSize.get(this.size);
    }
}
